<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="com.yaodian100.core.common.utils.ServerValue"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ include file="/taglibs.jsp"%>
<s:url value="/images" var="imgPath"/>
<!-- 月历 -->
<script type="text/javascript" charset="UTF-8" src="/js/jquery.datepick.js"></script>
<script type="text/javascript" charset="UTF-8" src="/js/jquery.datepick-zh-CN.js"></script>
<script language="javascript">
	$().ready( function() {
		$("#sort_${sortBy}").addClass("${sortByType}");
		$('#paramCreateDTStartD').datepick({minDate: null, showOn: 'both', 
	    	buttonImageOnly: true, buttonImage: '${imgPath}/calendar.gif',numberOfMonths:2,dateFormat:"yy-mm-dd",yearRange: '-50:+50'});
		$('#paramCreateDTEndD').datepick({minDate:new Date(), showOn: 'both', 
	    	buttonImageOnly: true, buttonImage: '${imgPath}/calendar.gif',numberOfMonths:2,beforeShow:customRange,dateFormat:"yy-mm-dd",yearRange: '-50:+50'});
		function customRange (){
			var startDt = $('#paramCreateDTStartD').val(); //起始日
			var endDt = new Date(parseInt(startDt.substring(0,4),10),parseInt(startDt.substring(5,7),10)-1,parseInt(startDt.substring(8,10),10)); //結束日
			return {minDate:endDt}; 
		}
	});
function sort(sortBy) {
	var formObj = document.forms[0];
	if(sortBy == formObj.sortBy.value) {
		if(formObj.sortByType.value == 'desc')
			formObj.sortByType.value = 'asc';
		else
			formObj.sortByType.value = 'desc';
	} else {
		formObj.sortBy.value = sortBy;
	}
		
	formObj.submit();
}
</script>
<link rel="stylesheet" type="text/css" href="/css/smoothness.datepick.css" />
<link rel="stylesheet" type="text/css" href="/css/jquery-ui-1.7.2.custom.css"/>
<s:actionerror cssClass="errmsg"/>
<s:actionmessage cssClass="errmsg"/>
<h1>批次排程管理 - 批次排程表</h1>
<div class="data-form">
      <s:form method="post" action="list.do">
      <s:hidden name="sortBy"/> <s:hidden name="sortByType"/>
        <div class="batchform">
          <div class="formrow">
            <label for="batchIdParam">排程编号：</label>
            <span><s:textfield name="paramEventId"/></span>
            <label for="batchStatusParam">排程状态：</label>
            <span><s:select name="paramStatus" list="menuStatus" headerKey="" headerValue="全部" listKey="code" listValue="desc"/></span>
          </div>
          <div class="formrow">
            <label for="batchTypeParam">执行项目：</label>
            <span><s:select name="paramBatchName" list="memuType.options" headerKey="" headerValue="全部" listKey="key" listValue="value.name"/></span>
            <label for="pmParam">建立人：</label>
            <span><s:select name="paramCreateUser" list="menuPM" headerKey="" headerValue="全部" listKey="username" listValue="nameNative"/></span>
          </div>
          <div class="formrow">
            <label for="startDate">批次建立时间：</label>
            <span><s:textfield maxlength="10" name="paramCreateDTStartD" id="paramCreateDTStartD" readonly="true"/>
            <s:select name="paramCreateDTStartT" list="menuTime" /></span>
            <span> ~ <s:textfield maxlength="10" name="paramCreateDTEndD" id="paramCreateDTEndD" readonly="true"/>
            <s:select name="paramCreateDTEndT" list="menuTime" /></span>
          </div>
          <div class="formrow"><label></label>
          <input type="button" onclick="this.form.submit();" value="查寻" class="sbmbtn">
          </div>
           <input type="button" onclick="this.form.action='/ecadmin/batch/product/delay/create.do';this.form.submit()" value="新增修改订制商品" class="sbmbtn">
           <yaodian100:checkPermission permissions="ROLE_BATCHSHELFADD">
          <input type="button" onclick="location.href ='/ecadmin/batch/shelf/add/create.do';" value="新增批次上架檔新增" class="sbmbtn">
          <input type="button" onclick="location.href ='/ecadmin/batch/shelf/promoteNameUpdate/create.do';" value="新增批次修改上架中商品促销小标" size="100"></input>
          
          </yaodian100:checkPermission>
          <input type="button" onclick="location.href ='/ecadmin/batch/product/moveMainCategoryOfProduct/create.do';" value="新增批次修改商品主分类" size="100"></input>
           <input type="button" onclick="location.href ='/ecadmin/batch/addOnProduct/add/create.do';" value="新增搭售商品/赠品" size="100"></input>
          <input type="button" onclick="location.href ='/ecadmin/batch/addOnProduct/update/create.do';" value="修改搭售商品/赠品" size="100"></input>
          <input type="button" onclick="location.href ='/ecadmin/batch/product/updateReturnRule/create.do';" value="新增修改商品退换货规则">
        </div>
      </s:form>
   
<h3 class="tword">查寻结果列表 - 共${pager.totalSize}笔</h3>
      <table width="100%" class="tb-1">
        <thead>
          <tr>
          <th><a href="javascript:;" onclick="sort('oid');" id="sort_oid">排程编号</a></th>
          <th><a href="javascript:;" onclick="sort('executeFunction');" id="sort_executeFunction">执行项目</a></th>
          <th><a href="javascript:;" onclick="sort('createUser');" id="sort_createUser">建立人</a></th>
          <th><a href="javascript:;" onclick="sort('createDate');" id="sort_createDate">批次建立时间</a></th>
          <th><a href="javascript:;" onclick="sort('modifyDate');" id="sort_modifyDate">批次修改时间</a></th>
          <th><a href="javascript:;" onclick="sort('startDate');" id="sort_startDate">开始排程时间</a></th>
          <th><a href="javascript:;" onclick="sort('runDate');" id="sort_runDate">开始执行时间</a></th>
          <th><a href="javascript:;" onclick="sort('endDate');" id="sort_endDate">结束执行时间</a></th>
          <th><a href="javascript:;" onclick="sort('status');" id="sort_status">排程状态</a></th>
          <th><a href="javascript:;" onclick="sort('recordSize');" id="sort_recordSize">修改资料笔数</a></th>
          <th><a href="javascript:;" onclick="sort('failSize');" id="sort_failSize">失败笔数</a></th>
          <th width="30"></th>
        </thead>
        <tbody>
<c-rt:forEach items="${batchEvents}" var="batch" varStatus="rows_index">
          <tr class="${rows_index.count % 2 == 0 ? 'bg-yl' : ''}">
           <td><a href="/ecadmin/batch/${batch.batchName}/view.do?batchEventId=${batch.oid}">${batch.oid}</a></td>
           <td>${memuType.options[batch.batchName].name}</td>
           <td>${batch.createUser}</td>
           <td><fmt:formatDate pattern="yyyy-MM-dd" value="${batch.createDate}" /><br /><fmt:formatDate pattern="HH:mm:ss" value="${batch.createDate}" /></td>
           <td><fmt:formatDate pattern="yyyy-MM-dd" value="${batch.modifyDate}" /><br /><fmt:formatDate pattern="HH:mm:ss" value="${batch.modifyDate}" /></td>
           <td><c:if test="${!empty batch.startDate}">
           <fmt:formatDate pattern="yyyy-MM-dd" value="${batch.startDate}" /><br /><fmt:formatDate pattern="HH:mm:ss" value="${batch.startDate}" /></c:if></td>
           <td><c:if test="${!empty batch.runDate}">
           <fmt:formatDate pattern="yyyy-MM-dd" value="${batch.runDate}" /><br /><fmt:formatDate pattern="HH:mm:ss" value="${batch.runDate}" /></c:if></td>
           <td><c:if test="${!empty batch.endDate}">
           <fmt:formatDate pattern="yyyy-MM-dd" value="${batch.endDate}" /><br /><fmt:formatDate pattern="HH:mm:ss" value="${batch.endDate}" /></c:if></td>
           <td>${batch.status.desc}</td>
           <td>${batch.recordSize}</td>
           <td>${batch.failSize}</td>
           <td><c:if test="${actorId eq batch.createUser}">
           <c:if test="${batch.editable}">
           		<a href="/ecadmin/batch/${batch.batchName}/edit.do?paramBatchEventId=${batch.oid}">修改</a></c:if><br />
           <c:if test="${batch.cancelable}">
           <a href="/ecadmin/batch/common/cancel.do?batchEventId=${batch.oid}">取消</a></c:if>
           </c:if>
           <c:if test="${actorId ne batch.createUser}">&nbsp;</c:if>
           </td>
          </tr></c-rt:forEach>
        </tbody>
      </table>
      <yaodian100:pageutil link="list.do" pagerObj="${pager}" />
</div>